using BlazorAdmin.Models;
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Components;

namespace BlazorAdmin.Web.Shared.Components
{
    /// <summary>
    /// TasksEdit.razor 编辑组件代码
    /// </summary>
    public partial class JobEdit
    {
        [Parameter]
        public Job? Value { get; set; }

        [Parameter]
        public EventCallback<Job>? ValueChanged { get; set; }

        private List<SelectedItem>? JobItems { get; set; }

        protected override void OnInitialized()
        {
            base.OnInitialized();

            if (0 == Value?.ID)
                Value.CronExpress = "0 30 17 * * ?";

            JobItems = new List<SelectedItem>
            {
                new(SysConsts.SyncClientDeviceInfo, "客户端上报设备信息"),
                new(SysConsts.UploadClientFile, "客户端文件备份"),
                new(SysConsts.PushWorkTimeToBI, "推送HRM出勤数据至BI")
            };
        }

        public async Task OnJobChanged(SelectedItem item)
        {
            Value.JobName = item.Text;
        }
    }
}
